(function () {
    let roof = document.querySelector('.roof')
let prod = document.querySelector('.product')
//页面滚动事件
window.addEventListener('scroll', function () {
    //document.documentElement值得是html
    //可以获取滚动的距离是多少
    if (document.documentElement.scrollTop >= prod.offsetTop) {
        roof.style.top = 0
    } else {
         roof.style.top = '-130px'
    }
    
})
//排他思想技术类
let product = document.querySelectorAll('.product-left li')
for (let i = 0; i < product.length; i++){
    product[i].addEventListener('mouseenter', function () {
        product[i].classList.add('jishu')
        product[i].style.display = 'block'
        product[i].style.backgroundColor = '#00c2b3'
        product[i].children[6].style.display = 'block'
    })  
    product[i].addEventListener('mouseleave', function () {
        document.querySelector('.jishu').classList.remove('jishu')
        product[i].classList.add('jishu')
        product[i].style.backgroundColor = '#ffffff'
        product[i].children[6].style.display = 'none'
    }) 
   
}
//侧边栏
let nav = document.querySelector('.nav')
//侧边栏底部
let navBottom = nav.querySelector('.nav-bottom')
nav.addEventListener('mouseenter', function () {
    nav.className = 'navgro'
})
nav.addEventListener('mouseleave', function () {
   nav.className = 'nav'
})
////侧边栏滚动到顶部ScrollTop
navBottom.children[0].addEventListener('click', function () {
    document.documentElement.scrollTop =0
})
//热招职位导航栏
let liss = document.querySelectorAll('.posi-top li')
let lis = document.querySelectorAll('.posi-top li a')
for (let i = 0; i < lis.length; i++){
    liss[i].addEventListener('mouseenter', function () {
            document.querySelector('.posi-top .posihead').classList.remove('posihead')
        this.classList.add('posihead')
    })
    lis[i].addEventListener('mouseenter', function () {
        document.querySelector('.posi-top .pink').classList.remove('pink')
    this.classList.add('pink')
})
}
}())
    //跳转页面
        let bood = document.querySelectorAll('.box .right .bood')
        let obj = JSON.parse(localStorage.getItem('key'))
      
        for (let i = 0; i < bood.length; i++){
            bood[i].addEventListener('click', function () {
                location.href='./register.html'
            })
            if (obj) {
            bood[i].innerHTML = `<a href="#">你好${obj.phone}</a>`
        }
        }